// pages/my/my.js
Page({
    /**
     * 页面的初始数据
     */
    data: {
        // bannerList: ['/static/avatar/lbx.jpeg', '/static/background/plane.png', '/static/avatar/lbx.jpeg'], // 轮播图数据
        userInfo: {

        },
        func: [
            {
                "id": 1,
                "name": "我的生词本",
                "class_name": "shengciben",
                "url": "/pages/myNewWordNote/myNewWordNote"
            },
            {
                "id": 2,
                "name": "我的收藏",
                "class_name": "shoucang",
                "url": "/pages/myCollect/myCollect"
            },
            {
                "id": 3,
                "name": "我的喜欢",
                "class_name": "xihuan",
                "url": "/pages/myLove/myLove"
            },
            {
                "id": 4,
                "name": "我的密码",
                "class_name": "mima",
                "url": "/pages/myPassword/myPassword"
            },
        ]
    },
    editPersonInfo: function () {
        console.log('点击文字跳转到目标页面并执行逻辑操作');
    },
    navigator: function (e) {
        const url = e.currentTarget.dataset.url;
        console.log("url==>", url);
        wx.navigateTo({
            url: url
        });
    },
    loginOut: function () {
        wx.showModal({
            title: '提示',
            content: '确定退出登录？',
            cancelColor: 'red',
            success: function (res) {
                if (res.confirm) {
                    console.log('用户点击确定');
                    wx.showLoading({
                        title: '正在退出...',
                        success: function () {
                            wx.removeStorageSync('loginUser');
                            wx.removeStorageSync('isLogin');
                            wx.navigateTo({
                                url: '/pages/login/login',//跳转到登录页面
                            });
                        },
                        fail: function () {
                            wx.showToast({
                                title: '异常',
                                icon: 'error',
                                duration: 2000
                            })
                        },
                        complete: function () {
                            setTimeout(function () {
                                wx.hideLoading();
                            }, 2000);
                        }
                    });
                } else if (res.cancel) {
                    console.log('用户点击取消');
                }
            }
        })
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        let loginUser = wx.getStorageSync('loginUser');//获取登录用户的信息
        console.log("user==>", loginUser);
        this.setData({
            'userInfo': loginUser,
        });
    },
})